<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增产品销量纪录')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-partsRebate-add">
            <input id="factoryId" name="factoryId" class="form-control" type="hidden">
            <input id="partsId" name="partsId" class="form-control" type="hidden">
            <input id="attributeId" name="attributeId" class="form-control" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">选择核算产品：</label>
                <div class="col-sm-8">
                    <input id="attributeName" name="attributeName" class="form-control" type="text" placeholder="请选择生成标签的产品" onclick="partsSelect()" readonly required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">核算销量/销售额：</label>
                <div class="col-sm-8">
                    <input id="rebateNumber" name="rebateNumber" class="form-control" onchange="updateMoney();" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">核算单价：</label>
                <div class="col-sm-8">
                    <input id="rebatePrice" name="rebatePrice" class="form-control" onchange="updateMoney();" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">核算服务费：</label>
                <div class="col-sm-8">
                    <input id="rebateMoney" name="rebateMoney" class="form-control" type="text" readonly required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="rebateRemark" class="form-control" type="text"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/partsRebate"
        $("#form-partsRebate-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-partsRebate-add').serialize());
            }
        }

        function partsSelect() {
            var url = ctx+"zsyh/parts/partsTag/";
            layer.open({
                type: 2,
                area: ['800px', '600px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "选择产品",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }


        function updateMoney() {
            debugger;
            var totalMoney=0;
            if(($("#rebateNumber").val() != '' && $("#rebateNumber").val() != null && $("#rebateNumber").val() != undefined) && ($("#rebatePrice").val() != '' && $("#rebatePrice").val() != null && $("#rebatePrice").val() != undefined)){
                totalMoney =($("#rebateNumber").val() * $("#rebatePrice").val() ).toFixed(2);
                $("#rebateMoney").val(totalMoney);
            }

        }
    </script>
</body>
</html>